# Maintainer: Felix Yan <felixonmars@archlinux.org>

_hkgname=LambdaHack
pkgname=haskell-lambdahack
pkgver=0.11.0.0
pkgrel=79
pkgdesc="A game engine library for tactical squad ASCII roguelike dungeon crawlers"
url="https://lambdahack.github.io"
license=("BSD")
arch=('loong64' 'x86_64')
depends=('ghc-libs' 'haskell-quickcheck' 'haskell-ansi-terminal' 'haskell-assert-failure'
         'haskell-async' 'haskell-base-compat' 'haskell-enummapset' 'haskell-file-embed'
         'haskell-hashable' 'haskell-hsini' 'haskell-keys' 'haskell-miniutter'
         'haskell-open-browser' 'haskell-optparse-applicative' 'haskell-pretty-show'
         'haskell-primitive' 'haskell-sdl2' 'haskell-sdl2-ttf' 'haskell-splitmix'
         'haskell-th-lift-instances' 'haskell-unordered-containers' 'haskell-vector'
         'haskell-vector-binary-instances' 'haskell-witch' 'haskell-zlib')
makedepends=('ghc' 'haskell-tasty' 'haskell-tasty-hunit' 'haskell-tasty-quickcheck')
source=("https://hackage.haskell.org/packages/archive/$_hkgname/$pkgver/$_hkgname-$pkgver.tar.gz")
sha256sums=('5526cddc753d86283c94f3072c5f5675af357a3b66c039265df55306fa62b5a5')

build() {
  cd $_hkgname-$pkgver

  runhaskell Setup configure -O --enable-shared --enable-executable-dynamic --disable-library-vanilla \
    --prefix=/usr --docdir=/usr/share/doc/$pkgname --datasubdir=$pkgname --datasubdir=haskell-lambdahack --enable-tests \
    --dynlibdir=/usr/lib --libsubdir=\$compiler/site-local/\$pkgid --ghc-option=-fllvm \
    --ghc-option=-optl-Wl\,-z\,relro\,-z\,now \
    --ghc-option='-pie' \
    -f-jsaddle -frelease -fsupportnodejs -fwith_costly_optimizations -f-with_expensive_assertions

  runhaskell Setup build $MAKEFLAGS
  runhaskell Setup register --gen-script
  runhaskell Setup unregister --gen-script
  sed -i -r -e "s|ghc-pkg.*update[^ ]* |&'--force' |" register.sh
  sed -i -r -e "s|ghc-pkg.*unregister[^ ]* |&'--force' |" unregister.sh
}

check() {
  cd $_hkgname-$pkgver
  runhaskell Setup test --show-details=direct
}

package() {
  cd $_hkgname-$pkgver

  install -D -m744 register.sh "$pkgdir"/usr/share/haskell/register/$pkgname.sh
  install -D -m744 unregister.sh "$pkgdir"/usr/share/haskell/unregister/$pkgname.sh
  runhaskell Setup copy --destdir="$pkgdir"
  install -D -m644 COPYLEFT -t "$pkgdir"/usr/share/licenses/$pkgname/
  rm -f "$pkgdir"/usr/share/doc/$pkgname/COPYLEFT
}
